/// ---------------------------------------------
///
/// 江懷玉
/// 
/// ---------------------------------------------


//
// 定义类型
//
function fnIntiListToolbar(t) {
    var t = $.data($("#tt")[0]);
    var grid = $.data($("#tt")[0], "datagrid").grid;
    var tb = $(".datagrid-toolbar");
    fnAddChild(t, grid, tb, "上传图片",UploadPic);
    fnAddChild(t, grid, tb, "图片信息维护", PicInfoManage);
}

function fnAddChild(t,grid,tb,name,fn) {
    $("<div class=\"datagrid-btn-separator\"></div>").appendTo(tb);
    // } else {
    var btn = {  
        text: name,
        iconCls: 'icon-remove',
        handler: fn
    };
    var tool = $("<a href=\"javascript:void(0)\"></a>");
    tool[0].onclick = eval(btn.handler || function () {
    });
    tool.css("float", "left").text(btn.text).attr("icon", btn.iconCls || "").appendTo(tb).linkbutton({ plain: true, disabled: (btn.disabled || false) });
}

//上传图片
function UploadPic() {
    if (typeof (parent.addTab) == "function") {
        var selected = $('#tt').datagrid('getSelected');
        if (selected == null) {
            alert("请选择相关记录");
        }
        parent.myUploadWindows("/Web/TestUpload.aspx?groupid="+ selected.GroupId);
        //parent.addTab(selected.GroupName + ":" + selected.GroupCode, "HtmlWindows/PostList.aspx?entity=Post&ApplicationId=" + selected.ApplicationId + "&GroupId=" + selected.GroupId);
    }
}

//图片信息维护
function PicInfoManage() {
    if (typeof (parent.addTab) == "function") {
        var selected = $('#tt').datagrid('getSelected');
        if (selected == null) {
            alert("请选择相关记录");
        }
        parent.addTab(selected.GroupName , "HtmlWindows/List.aspx?entity=Albums&condition="+encodeURIComponent("GroupId='"+selected.GroupId+"'"));
    }
    // addTab(title, href)
}